package com.hfh.jdbc;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Author hfh
 * @Date 2022 09 20 10 12
 **/
public class JDBCTest3 {
    public static void main(String[] args) {
        Connection con = null;
        PreparedStatement ps = null;
        try {
            con = DBUtils.getConnection();
            String sql = "update beauty set photo = ? where id = 1 ";
            ps = con.prepareStatement(sql);
            InputStream is = new FileInputStream("day27/src/img.png");
            ps.setBlob(1,is);
            int i = ps.executeUpdate();
            System.out.println(i);
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }finally {
            DBUtils.close(con,ps,null);
        }
    }
}
